#!/usr/local/bin/python

import os, sys
from string import lower

if len(sys.argv) >= 2:
    _dir = sys.argv[1]
else:
    _dir = os.getcwd()

def numeric_compare(x, y):
    return x - y

"""
temp_files = os.listdir(_dir)
sorting_list = []

i = 1
for _file in temp_files:
    base, ext = os.path.splitext(_file)
    sorting_list.append(int(base.split('-')[1]))  

sorted_list = sorted(sorting_list, cmp=numeric_compare)

for _file in os.listdir(_dir):
    base, ext = os.path.splitext(_file)
    
    i = sorted_list.index(int(base.split('-')[1]))
    res_color = lower(_dir.split("/")[len(_dir.split("/")) - 1])
    name = lower(_dir.split("/")[len(_dir.split("/")) - 2])
    
    new_file_name = "%s_%s.%04d%s" % (name, res_color, (i + 1), lower(ext))
    current_file_dir = os.path.join(_dir, _file)
    
    os.rename(current_file_dir, os.path.join(_dir, new_file_name))
 """   









